package cn.iocoder.yudao.module.mqtt.framework.handler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.MessagingException;
import org.springframework.stereotype.Component;

@Component
public class ReceiverMessageHandler implements MessageHandler {

   // @Autowired
   // private TbLampService tbLampService ;

  //  @Autowired
   // private TbLampStatusService tbLampStatusService ;

    @Override
    public void handleMessage(Message<?> message) throws MessagingException {
        String payload = message.getPayload().toString();
        System.out.println("---" + payload);
        MessageHeaders headers = message.getHeaders();
        String topicName = headers.get("mqtt_receivedTopic").toString();
        System.out.println(topicName);
        if("atguigu/iot/lamp/line".equals(topicName)) {
            //tbLampService.updateLampOnlineStatus(payload) ;
        }else if("atguigu/iot/lamp/device/status".equals(topicName)) {
          //  tbLampStatusService.saveDeviceStatus(payload) ;
        }
    }

}
